package com.ljh.mall.mallsearch.controller;

import com.ljh.mall.mallsearch.service.MallSearchService;
import com.ljh.mall.mallsearch.vo.SearchParam;
import com.ljh.mall.mallsearch.vo.SearchResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @author ：刘剑鸿
 * @date ：Created in 2023/2/1 15:44
 * @description：
 * @modified By：
 * @version: $
 */
@Controller
public class SearchController {

    @Autowired
    private MallSearchService mallSearchService;

    @GetMapping(value = {"/list.html","/","/index.html"})
    public String listPage(SearchParam param, Model model){

        SearchResult search =mallSearchService.search(param);
        System.out.println("数据"+search);
        model.addAttribute("result",search);
        return "index";
    }
}
